#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    LL n;
    cin >> n;
    string s;
    cin >> s;

    int m0 = 0, m1 = 0;

    for(int i = 0; i < s.length(); i ++){
        if(s[i] == '0') m0 ++;
        else m1 ++;
    }

    LL l = 1ll << m1;
    LL r = (1ll << (s.length())) - (1ll << m0) + 1;

    for(int i = l; i <= r; i ++) cout << i << " ";

    return 0;
}